package edu.buaa.agent;

import net.bytebuddy.ByteBuddy;
import net.bytebuddy.implementation.FixedValue;

import static net.bytebuddy.matcher.ElementMatchers.named;

public class TestBuddy {
    public static void main(String[] args) throws InstantiationException, IllegalAccessException {
        Class<?> dynamicType = new ByteBuddy()
                .subclass(Object.class)
                .method(named("toString"))
                .intercept(FixedValue.value("Hello World!"))
                .make()
                .load(TestBuddy.class.getClassLoader())
                .getLoaded();
        System.out.println(dynamicType.newInstance().toString());

        System.currentTimeMillis();
        Class<?> dynamicType2 = new ByteBuddy()
//                .rebase(named("fda"))
                .subclass(Object.class)
                .method(named("toString"))
                .intercept(FixedValue.value("Hello World!"))
                .make()
                .load(TestBuddy.class.getClassLoader())
                .getLoaded();
        System.out.println(dynamicType.newInstance().toString());
    }
}
